package algorithm.action;

import java.util.Stack;

public class StackToQueue {

	public static void main(String[] args) {
		StackToQueue queue = new StackToQueue();
		
		for(int i = 0; i < 5; i++) {
			queue.push(i);
		}
		for(int i = 0; i < 4; i++) {
			System.out.println(queue.pop());
		}
	}
	
	Stack<Integer> stack1 = new Stack<Integer>();
	Stack<Integer> stack2 = new Stack<Integer>();
	
	public void push(int node) {
		stack1.push(node);
	}
	
	public int pop() {
		if(stack2.isEmpty()) {
			while(!stack1.isEmpty()) {
				stack2.push(stack1.pop());
			}
		}
		return stack2.pop();
	}
}
